<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>string</title>
    <script>
    var  a ="hello 'javascript'";
    document.write(a)
    console.log(a.length)
    console.log(a[2]);
    var b = new String("duixiang");
    console.log(typeof a);
    console.log(typeof b);
    // 字符串自带方法
    console.log(a.indexOf("hello"));
    console.log(a.indexOf("heloo"));//第一次出现的位置
    console.log(a.lastIndexOf("t",3));//从索引5开始 从后往前 查找字符串最后一次出现的位置 
    
    console.log(a.slice(0,5)); //第一个参数是开始索引 第二个是结束索引
    console.log(a.substr(0,3));//第二个参数代表截取的长度

    var aa = a.replace("'javascript'","java");
    console.log(aa);
    var AA = a.toUpperCase();
    console.log(AA);
    console.log(AA.toLowerCase());
    var testTrim = "   hello    ";
    console.log(testTrim.trim());
    console.log(testTrim.charAt(7));//提取下标对应字符
    console.log(testTrim.charCodeAt(7))//下标字符Unicode

    var c = "a b c d";
    var array = c.split(" ");
    console.log(typeof array+" "+array);//字符串转换成数组
    
    var d="hello  javascript";
     console.log(d.split(""));
     console.log(d.split("").reverse());
     console.log(d.split("").reverse().join(""));
    </script>
</head>
<body>
    
</body>
</html>